package com.kaiyidiannao.db;

import android.content.Context;
import android.database.Cursor;
import android.database.sqlite.SQLiteCursor;
import android.database.sqlite.SQLiteCursorDriver;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteQuery;
import android.database.sqlite.SQLiteDatabase.CursorFactory;
import android.database.sqlite.SQLiteOpenHelper;
import android.util.Log;

public class DBHelper extends SQLiteOpenHelper {
	public static final String TAG = "SQLiteDemo";
	public static final String DB_NAME = "mydb.db";
	public static final int VERSION = 2;

    public DBHelper(Context context) {
        //super(context, DB_NAME, null, VERSION);
        super(context, DB_NAME, null, VERSION);
    }


    @Override
	public void onCreate(SQLiteDatabase db) {
		Log.d(TAG, "Database on create");
        db.execSQL("DROP TABLE IF EXISTS " +"m_userinfo");
		String sql = "CREATE TABLE m_userinfo(_id INTEGER PRIMARY KEY AUTOINCREMENT, itemid VARCHAR(256), title VARCHAR(256),userid VARCHAR(256))";
		db.execSQL(sql);

	}

	@Override
	public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
		Log.d(TAG, "Database on upgrade old version " + oldVersion + ", new version " + newVersion);		
	}

}
